import ElementPlus from "element-plus";
import * as ElementPlusIconsVue from "@element-plus/icons-vue"
import { createApp } from "vue"
import { MotionPlugin } from "@vueuse/motion";
import { createPinia } from "pinia"
import persist from "pinia-plugin-persist";
import { permission } from "@/directive/permission"
// 重置样式
import "./style/reset.scss";
// 导入公共样式
import "./style/index.scss";
import "element-plus/dist/index.css"
// 引入element-plus中文包
import zhCn from "element-plus/es/locale/lang/zh-cn"

import App from "./App.vue"
import router from "@/router"
// 注册路由守卫
import "@/router/permission"

// 创建 Pinia 实例
const pinia = createPinia();

// 使用 pinia-plugin-persist 插件
pinia.use(persist);

// 将 Pinia 实例暴露到全局 (window 对象)
window.pinia = pinia;

const app = createApp(App)

app.use(pinia)
// 使用中文语言包
app.use(ElementPlus, { locale: zhCn })
app.use(MotionPlugin)
app.use(router)

// 导入所有element-plus的图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 注册自定义指令(按钮权限校验)
permission(app)

// 挂载根dom
app.mount("#app")